package org.example.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.exception.AppExceptionCodeMsg;
import org.example.pojo.MedicalRecord;
import org.example.query.MedicalRecordQuery;
import org.example.service.IMedicalRecordService;
import org.example.vo.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author peak
 * @since 2024-12-18
 */
@RestController
@RequestMapping("/medicalrecord")
public class MedicalRecordController extends BaseController<MedicalRecord, MedicalRecordQuery> {
    @Autowired
    private IMedicalRecordService medicalRecordService;
    //根据挂号id来查询病例
    @GetMapping("/register/{rid}")
    public ResultBean register(@PathVariable("rid") Integer registerId) {
        QueryWrapper<MedicalRecord> queryWrapper = new QueryWrapper<>();
        MedicalRecord medicalRecord = medicalRecordService.getOne(queryWrapper.eq("register_id", registerId));
        return medicalRecord!=null? ResultBean.SUCCESS(medicalRecord):ResultBean.ERROR(AppExceptionCodeMsg.DATA_NOT_FOUND);
    }
}
